package com.yeswater.multithread.chapter1.test1_7;

/**
 * author : yeswater
 * date : 2023/10/18
 *
 *
 * Thread.currentThread().getStackTrace() 堆栈跟踪元素数组
 */

public class Test1 {

    public static void main(String[] args) {
        Test1 test1 = new Test1();
        test1.a();
    }

    public void a() {
        b();
    }

    public void b() {
        c();
    }

    public void c() {
        d();
    }

    public void d() {
        e();
    }

    public void e() {
        StackTraceElement[] array = Thread.currentThread().getStackTrace();
        if (array != null) {
            for (int i = 0; i < array.length; i++) {
                StackTraceElement eachElement = array[i];
                System.out.println("className=" + eachElement.getClassName() +
                        " methodName=" + eachElement.getMethodName() +
                        " fileName=" + eachElement.getFileName() +
                        " lineNumber=" + eachElement.getLineNumber());
            }
        }
    }
}
